#include <iostream>
#include <signal.h>
#include <unistd.h>

volatile int flag = 0;

void handler(int signo)
{
    std::cout << "signo: " << signo << std::endl;
    flag = 1;
    std::cout << "change flag to: " << flag << std::endl;
}

int main()
{
    signal(2, handler);
    std::cout << "getpid: " << getpid() << std::endl;
    while(!flag);
    std::cout << "quit normal!" << std::endl;
}